﻿<%@ Control Language="C#" AutoEventWireup="true" Inherits="Portal.Core.ActionFlow.ActionUserControl" %>
<%@ Import Namespace="Portal.Data.Security" %>
<link href='/Themes/css/private/Login.css' rel='stylesheet' type='text/css' />
<script type="text/javascript">
    jQuery(document).ready(function ($) {
        $('#<%=Username.ClientID %>').focus();
        var Login = $('#<%=Login.ClientID %>');
        $('#<%=Password.ClientID %>').keyup(function (e) {
            if (e.keyCode == 13) {
                Login.click();
            }
        });
        $('#<%=Username.ClientID %>').keyup(function (e) {
            if (e.keyCode == 13) {
                Login.click();
            }
        });
    });

    function valid() {
        var nick = $('#<%=Username.ClientID%>');
        if (nick.val().length == 0) {
            nick.focus();
            return false;
        }
        
        var pass = $('#<%=Password.ClientID%>');
        if (pass.val().length == 0) {
            pass.focus();
            return false;
        }
        return true;
    }
</script>
<center>
    <div class="login">
        <div class="log1">
        </div>
        <div class="log2">
        </div>
        <div class="log3">
            <table cellpadding="2" cellspacing="2" style="margin-left: 20px; width: 295px">
                <tr>
                    <td>
                        <asp:TextBox ID="Username" placeholder="Tài khoản"  runat="server" CssClass="LoginTextField"></asp:TextBox>
                    </td>
                    
                </tr>
                <tr>
                    <td >
                        <asp:TextBox ID="Password" placeholder="Mật khẩu" runat="server" CssClass="LoginTextField" TextMode="Password"></asp:TextBox>
                    </td>
                    
                </tr>
                <tr>
                    <td style="width: 130px">
                        <asp:Button ID="Login" runat="server" CssClass="buttonlogin" Text="Login" OnClick="Login_Click" OnClientClick="return valid();"/>
                    </td>
                 
                </tr>
                <tr>
                    <td style="padding-top: 10px;">
                        <asp:Label ID="Message" runat="server" CssClass="TextErrorMessage"></asp:Label>
                    </td>
                </tr>
            </table>
        </div>
        <div class="log4">
        </div>
        <div class="log5">
            <strong></strong>
        </div>
    </div>
</center>
<script runat="server">
    protected override string ModuleName
    {
        get
        {
            return "login";
        }
    }

    protected override string Action
    {
        get
        {
            return "login";
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Login_Click(object sender, EventArgs e)
    {
        if (SecurityProvider.Instance.LogIn(Username.Text, Password.Text))
        {
            Response.Redirect("/Admin_Home.aspx", true);
        }
        else
        {
            Message.Text = "Invalid username or password";
        }
    }
</script>